package com.avril.db;

import com.avril.constants.DBConstants;
import com.avril.entity.OrderDetail;
import com.avril.util.ErrorManager;

public class OrderDetailDao {
	SqlManager manage = null;

	public OrderDetailDao() {
		super();
		manage = SqlManager.createInstance();
		manage.connectDB();
	}

	public boolean addOrderDetail(OrderDetail orderDetail) {
		boolean result = false;
		try {
			Object[] params = new Object[] {
					orderDetail.getGoods().getGoodsCode(),
					orderDetail.getDisPrice(), orderDetail.getAmount(),
					orderDetail.getTotalPrice(), orderDetail.getOrderId(),
					orderDetail.getInOrOut() };
			String sql = "insert into detail(goodscode,disprice,amount,totalprice,orderid,inorout) values(?,?,?,?,?,?)";
			result = manage.executeUpdate(sql, params, DBConstants.PSTM_TYPE);
			manage.closeDB();
		} catch (Exception e) {
			ErrorManager.printError("OrderDetailDao.addOrderDetail", e);
		}
		return result;

	}

}
